#encoding: utf-8

# class Student(object):
# 	"""
# 		docstring for Student
# 		__init__是一个特殊方法用于在创建对象时进行初始化操作
# 		通过这个方法我们可以为学生对象绑定name和age两个属性
# 	"""
# 	def __init__(self, name, age):
# 		super(Student, self).__init__()
# 		self.name = name
# 		self.age = age

# 	def study(self, course_name):
# 		print('%s正在学习%s' % (self.name, course_name))
# 		pass

# 	def watch_tv(self):
# 		if self.age <18:
# 			print('%s 看熊出没' % self.name)
# 		else:
# 			print('%s 看NBA ' % self.name)
		
# def main():
# 	stu1 = Student('李小进', 30)

# 	stu1.study('Python')

# 	stu1.watch_tv()

# 	stu2 = Student('李小进2', 15)

# 	stu2.study('Python2')

# 	stu2.watch_tv()

# if __name__ == '__main__':
# 	main()


# class Test(object):
# 	"""docstring for ClassName"""
# 	def __init__(self, foo):
# 		super(Test, self).__init__()
# 		self.__foo =  foo

# 	def __bar(self):
# 		print(self.__foo)
# 		print('__bar')

# def main():
# 	test = Test('hello')
# 	 # 'Test' object has no attribute '__bar'
# 	# test.__bar()
# 	 # 'Test' object has no attribute '__foo'
# 	# print(test.__foo)

# 	test._Test__bar()
# 	print(test._Test__foo)



# 	pass
		

# if __name__ == '__main__':
# 	main()


# 练习
# 定义一个类描述平面上的点并提供移动点和计算到另一个点距离的方法。


from math import sqrt

class Point(object):
	"""docstring for Point"""
	def __init__(self, x = 0 , y = 0):
		super(Point, self).__init__()
		self.x = x
		self.y = y

	def move_to(self, x, y):
		self.x = x
		self.y = y
		pass

	def move_by(self, x, y):
		self.x += x
		self.y += y
		pass

	def distanch_to(self, other):

		dx = self.x - other.x
		dy = self.y - other.y
		return sqrt(dx**2 + dy**2)

	def __str__(self):
		return ('(%s, %s)' % (str(self.x), str(self.y)))
		pass

def main():
	p1 = Point(3, 5)
	p2 = Point()

	p1.move_to(3, 6)
	p1.move_by(1, 1)


	print(p1.distanch_to(p2))



	pass

if __name__ == '__main__':
	main()







